import Vue from 'vue'
import VueRouter from 'vue-router'

/* Layout */
import Layout from '@/layout/index.vue'
import Blank from '@/layout/blank.vue'

Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
    {
        path: '/',
        name: 'layout',
        component: Layout, // 修改为 Layout 组件
        children: [
            {
                path: '',
                name: 'home',
                component: () => import( '@/views/basic/HomeView.vue')
            },
            {
                path: 'change-password',
                name: 'change-password',
                component: () => import(/* webpackChunkName: "about" */ '@/views/basic/ChangePasswordView.vue')

            },
            {
                path: 'about',
                name: 'about',
                component: () => import( '@/views/basic/AboutView.vue'),
            },],
        /*        children: [

                    // admin
                    {
                        path: 'admin/import-student',
                        name: 'admin-import-student',
                        component: () => import('@/views/admin/ImportStudentView.vue')
                    },
                    {
                        path: 'admin/import-volunteer',
                        name: 'admin-import-volunteer',
                        component: () => import('@/views/admin/ImportVolunteerView.vue')
                    },
                    {
                        path: 'admin/import-grade',
                        name: 'admin-import-grade',
                        component: () => import('@/views/admin/ImportGradeView.vue')
                    },
                    {
                        path: 'admin/gather-grade',
                        name: 'admin-gather-grade',
                        component: () => import('@/views/admin/GatherView.vue')
                    },
                    // judge
                    {
                        path: 'judge/summary',
                        name: 'judge-summary',
                        component: () => import('@/views/judge/AssessSummaryIndexView.vue'),
                    },
                    {
                        path: 'judge/research',
                        name: 'judge-research',
                        component: () => import('@/views/judge/AssessResearchIndexView.vue')
                    },
                    {
                        path: 'judge/position',
                        name: 'judge-position',
                        component: () => import('@/views/judge/AssessPositionIndexView.vue')
                    },
                    {
                        path: 'judge/practice',
                        name: 'judge-practice',
                        component: () => import('@/views/judge/AssessPracticeIndexView.vue')
                    },
                    {
                        path: '/judge/assess-summary',
                        name: 'judge-assess-summary',
                        component: () => import('@/views/judge/AssessSummaryView.vue'),
                    },
                    {
                        path: '/judge/assess-research',
                        name: 'judge-assess-research',
                        component: () => import('@/views/judge/AssessResearchView.vue'),
                    },
                    {
                        path: '/judge/assess-position',
                        name: 'judge-assess-position',
                        component: () => import('@/views/judge/AssessPositionView.vue'),
                    },
                    {
                        path: '/judge/assess-practice',
                        name: 'judge-assess-practice',
                        component: () => import('@/views/judge/AssessPracticeView.vue'),
                    },


                    // student
                    {
                        path: 'student/information',
                        name: 'student-information',
                        component: () => import('@/views/student/StudentInformationView.vue'),
                    },
                    {
                        path: 'student/contact-information',
                        name: 'student-contact-information',
                        component: () => import('@/views/student/StudentContactInformationView.vue')
                    },
                    {
                        path: 'student/summary',
                        name: 'student-summary',
                        component: () => import('@/views/student/StudentSummaryView.vue'),
                    },
                    {
                        path: 'student/research',
                        name: 'student-research',
                        component: () => import('@/views/student/StudentResearchView.vue'),
                    },
                    {
                        path: 'student/position',
                        name: 'student-position',
                        component: () => import('@/views/student/StudentPositionView.vue'),
                    },
                    {
                        path: 'student/practice',
                        name: 'student-practice',
                        component: () => import('@/views/student/StudentPracticeView.vue'),
                    },
                ]*/
    },
    {
        path: '/login',
        name: 'login',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '@/views/basic/LoginView.vue')
    },
    {
        path: '/register',
        name: 'register',
        component: () => import(/* webpackChunkName: "about" */ '@/views/basic/RegisterView.vue')
    },
    {
        path: '/judge/assess',
        component: Blank,
        children: [
            {
                path: 'summary',
                component: () => import('@/views/judge/AssessSummaryView.vue'),
            },
            {
                path: 'research',
                component: () => import('@/views/judge/AssessResearchView.vue'),
            },
            {
                path: 'position',
                component: () => import('@/views/judge/AssessPositionView.vue'),
            },
            {
                path: 'practice',
                component: () => import('@/views/judge/AssessPracticeView.vue'),
            },
        ]

    },

]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
